<template>
  <div class="code" @click="refreshCode">
    <SIdentify :identifyCode="identifyCode"></SIdentify>
  </div>
</template>
<script>
  import {
    identifyCode
  } from '../api.js'
  import {
    mapState
  } from 'vuex'
  import SIdentify from '../components/identify'
  export default {
    name: "codetest",
    data() {
      return {
        identifyCodes: "1234567890",
        identifyCode: "",
        auth_code: ""
      };
    },
    components: {
      'SIdentify': SIdentify
    },
    mounted() {
      this.getTableDate()
      this.identifyCode = "";

    },
    methods: {
      //获取表格数据
      getTableDate() {
        identifyCode().then(res => {
          if (res.ErrorCode == 0) {
            this.identifyCode = res.Data.verify_code
            this.auth_code = res.Data.auth_code
            this.$store.commit("refreshNewCode", {
              identifyCode: this.identifyCode,
              auth_code: this.auth_code
            })
          } else {
            this.$message.error(res.ErrorMsg);
          }
        })
      },
      randomNum(min, max) {
        return Math.floor(Math.random() * (max - min) + min);
      },
      refreshCode() {
        this.identifyCode = "";
        this.getTableDate()
      },
    }
  };
</script>
<style scoped>
  .code {
    position: absolute;
    top: 0;
    right: 0;
    height: 430px;
  }
</style>